/**
 * Created by zzc on 2017/12/12
 */


'use strict'

import React, {Component} from 'react';

import {
    View,
    Text,
    Image,
    StyleSheet
} from 'react-native';

import { AppStyles, AppSizes,AppColors} from '@theme/';
import Button from 'apsl-react-native-button';
import {deviceHeight} from "../util/ScreenUtil";

export class EmptyView extends React.PureComponent {

    constructor(props) {
        super(props);
    }

    _onPress = () => {
        this.props.onPress();
    };

    render() {
        let hasTx = this.props.title && (this.props.title !== "");
        let hasBtn = this.props.btnText && this.props.btnText !== "";
        return (
            <View style={[AppStyles.container,AppStyles.containerCentered]}>
                <Image resizeMode='stretch' source={this.props.imgSource} style={{height: 120, width: 120,}}/>
                {hasTx ? <Text style={[styles.text_desc, this.props.textStyle]}>{this.props.title}</Text> : null}
                {hasBtn ?
                    <Button buttonStyle={[styles.btnContainer, this.props.buttonStyle]}
                            onPress={() => this._onPress()}
                            title={this.props.btnText}
                            textStyle={styles.btn_text_style}/> : null
                }
            </View>
        );
    }
}



const styles = StyleSheet.create({
    container: {
        flex: 1,
        flexDirection: 'column',
        paddingTop: deviceHeight / 5,
        alignItems: "center",
    },
    btnContainer: {
        height: 39,
        justifyContent: 'center',
        alignItems: 'center',
        width: 140,
        borderColor: 'black',
        borderRadius: 3,
        borderWidth: 0.6,
    },
    text_desc: {
        fontSize: 14,
        color: AppStyles.c,
        marginBottom: 25,
    },
    btn_text_style: {
        fontSize: 17,
        color: 'black',
    },

});
